package com.jzg.mvc.api.user;


import java.util.List;

import com.jfinal.aop.Inject;
import com.jfinal.core.Path;
import com.jfinal.kit.StrKit;
import com.jzg.common.controller.BaseController;
import com.jzg.common.model.sys.SysOrg;
import com.jzg.common.render.ZtreeNode;
import com.jzg.mvc.sys.org.OrgService;


@Path(value = "/api/org", viewPath = "")
public class OrgControler extends BaseController{
	
	@Inject
	private OrgService srv;
	
	/***
     * 获取树
     */
    public void selectTree(){
    	Boolean open = true;//是否展开所有
    	Boolean ifOnlyLeaf = false;//是否只选叶子
    	if(StrKit.notBlank(getPara("ifOnlyLeaf"))){//是否查询所有孩子
    		if("1".equals(getPara("ifOnlyLeaf"))){
    			ifOnlyLeaf = true;
    		}
    	}
		List<SysOrg> menuList = srv.getChildrenAllTree("root",null);
    	List<ZtreeNode> nodelist =srv.toZTreeNode(menuList,open,ifOnlyLeaf);//数据库中的菜单
    	renderJson(nodelist);
    }
	
}
